package com.whz.generic.memqueue.configure;

import com.whz.generic.memqueue.disruptor.MemDisruptorQueue;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author whz
 */
@Configuration
@ConditionalOnProperty(value = "generic.memqueue.enable", havingValue = "on")
@EnableConfigurationProperties(MemQueueProperty.class)
public class MemQueueConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public MemQueueProperty createMemQueueProperty() {
        return new MemQueueProperty();
    }

    @Bean
    public MemDisruptorQueue createMemDisruptorQueue(MemQueueProperty memQueueProperty) {
        return new MemDisruptorQueue(memQueueProperty);
    }
}
